package apiday02homework;

public class MatchesDemo {
    public static void main(String[] args) {
        /*
        String email = "2679459676@qq.com";
        String regex ="[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        boolean matches = email.matches(regex);
        if (matches) {
            System.out.println("邮箱格式正确");
        } else {
            System.out.println("邮箱格式错误");
        }

         */
        String email = "2679459676@qq.com";
        String regex ="[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        boolean matches = email.matches(regex);
        if (matches) {
            System.out.println("邮箱格式正确");
        }
        else {
            System.out.println("邮箱格式错误");
        }
    }
}
